with System.Storage_Elements; use System.Storage_Elements;

with win32api_interface;      use win32api_interface;
--with Win32; use Win32;
--with Interfaces.C;

package ffxilog_interface is
  type line_type is
    (Area,
     iTell, oTell,
     iLinkshell, oLinkshell,
     iParty, oParty,
     iSay, oSay,
     iShout, oShout,
     other, program);
  type Log_Line(length : integer) is record
    whatis : line_type;
    text   : string (1..length);
  end record;
  type starting_content_type is record
    text   : string (1..300);
    length : integer;
  end record;

  type Log_Info_Type is private;

  function Get_Pointer_To_Log_Info(Access_Handle         : in Handle;
                                   FFXIMain_base_address : in Address)
                                   return Log_Info_Type;
  -- Retrieves the base Log address

  function Get_Log(Access_Handle    : in Handle;
                   Log_Info_Address : in Log_Info_Type) return string;
  -- Gets the whole current Log in a string

  function Get_Archived_Log(Access_Handle    : in Handle;
                            Log_Info_Address : in Log_Info_Type;
                            last_valid_line  : in integer) return string;
  -- Gets the old lines of the Log from a given line number

  function Get_Number_of_Lines(Access_Handle    : in Handle;
                               Log_Info_Address : in Log_Info_Type)
                               return Integer;
  -- Retrieves the number of lines

  function Get_Line(Current_Log : in string;
                    line        : in integer) return Log_Line;
  -- Gets the text content from a whole content Log string.
private
  FFXiMainStaticOffset       : constant Storage_Offset := 16#576D58#;
  Offset_To_Line_Number      : constant Storage_Offset := 200;
  Offset_To_Log_Size         : constant Storage_Offset := 216;
  Offset_To_Current_Log_Ptr  : constant Storage_Offset := 204;
  Offset_To_Archived_Log_Ptr : constant Storage_Offset := 208;

  type Log_Info_Type is new Address;

  Max_Lines : constant Integer := 50;
  Last_Size : Storage_Offset;

  function Get_Log_Size               (Access_Handle    : in Handle;
                                       Log_Info_Address : in Address)
                                       return integer;
  function Get_Pointer_To_Current_Log (Access_Handle    : in Handle;
                                       Log_Info_Address : in Address)
                                       return Address;
  function Get_Pointer_To_Archived_Log(Access_Handle    : in Handle;
                                       Log_Info_Address : in Address)
                                       return Address;
end ffxilog_interface;
